#include <51func.h>
#define NUM 10000000
int main(int argc, char *argv[])
{
    int shmid = shmget(0x1234,4096,IPC_CREAT|0600);
    printf("shmid = %d\n", shmid);
    int * p = (int *)shmat(shmid,NULL,0);
    p[0] = 0;
    if(fork()){
        for(int i = 0; i < NUM; ++i){
            ++p[0];
        }
        wait(NULL);
        printf("p[0] = %d\n", p[0]);
    }
    else{
        for(int i = 0; i < NUM; ++i){
            ++p[0];
        }
    }
    shmdt(p);
    return 0;
}

